//TABLE A.I - EFFECTS ON GPA: ALTERNATIVE STANDARD ERRORS
use gpa_semester, clear

reghdfe gpa treat_post, absorb(geoid_blkgrp#semester mystd_id cohort#year) cluster(match_zip)
reghdfe gpa treat_post, absorb(geoid_blkgrp#semester mystd_id cohort#year) cluster(match_zip year)
reghdfe gpa treat_post, absorb(geoid_blkgrp#semester mystd_id cohort#year) cluster(catchment)
reghdfe gpa treat_post, absorb(geoid_blkgrp#semester mystd_id cohort#year) cluster(geoid_tract)

//TABLE A.II - EFFECTS ON PERCEPTIONS OF SAFETY
use ses, clear

reghdfe safe1 treat_post, absorb(mystd_id geoid_blkgrp#year cohort#year) cluster(match_zip)
reghdfe safe2 treat_post, absorb(mystd_id geoid_blkgrp#year cohort#year) cluster(match_zip)
reghdfe safe3 treat_post, absorb(mystd_id geoid_blkgrp#year cohort#year) cluster(match_zip)
reghdfe safe_avg treat_post, absorb(mystd_id geoid_blkgrp#year cohort#year) cluster(match_zip)

reghdfe unsafe1 treat_post, absorb(mystd_id geoid_blkgrp#year cohort#year) cluster(match_zip)
reghdfe unsafe2 treat_post, absorb(mystd_id geoid_blkgrp#year cohort#year) cluster(match_zip)
reghdfe unsafe3 treat_post, absorb(mystd_id geoid_blkgrp#year cohort#year) cluster(match_zip)
reghdfe unsafe_avg treat_post, absorb(mystd_id geoid_blkgrp#year cohort#year) cluster(match_zip)

//TABLE A.III - EFFECT ON GPA BY STUDENT RACE: MATCHED SAMPLE
use gpa_semester_reweight, clear

reghdfe gpa treat_post [aweight=weight] if std_blackhispanic, absorb(geoid_blkgrp#semester mystd_id cohort#year) cluster(match_zip)

//TABLE A.IV - EFFECTS ON GPA BY WEAPON TYPE
use gpa_semester_DA, clear

reghdfe gpa tp_none tp_knife tp_gun, absorb(geoid_blkgrp#semester mystd_id cohort#year) cluster(match_zip)
reghdfe gpa tp_none tp_knife tp_gun tp_density tp_inc tp_diversity tp_homicide tp_media tp_resident tp_male tp_age, absorb(geoid_blkgrp#semester mystd_id cohort#year) cluster(match_zip)
reghdfe gpa tp_none tp_knife tp_gun_noattack tp_gun_attack, absorb(geoid_blkgrp#semester mystd_id cohort#year) cluster(match_zip)
reghdfe gpa tp_none tp_knife tp_gun_noattack tp_gun_attack tp_density tp_inc tp_diversity tp_homicide tp_media tp_resident tp_male tp_age, absorb(geoid_blkgrp#semester mystd_id cohort#year) cluster(match_zip)

reghdfe gpa tp_none tp_knife tp_gun if sht_black | sht_hispanic, absorb(geoid_blkgrp#semester mystd_id cohort#year) cluster(match_zip)
reghdfe gpa tp_none tp_knife tp_gun tp_density tp_inc tp_diversity tp_homicide tp_media tp_resident tp_male tp_age if sht_black | sht_hispanic, absorb(geoid_blkgrp#semester mystd_id cohort#year) cluster(match_zip)
reghdfe gpa tp_none tp_knife tp_gun_noattack tp_gun_attack if sht_black | sht_hispanic, absorb(geoid_blkgrp#semester mystd_id cohort#year) cluster(match_zip)
reghdfe gpa tp_none tp_knife tp_gun_noattack tp_gun_attack tp_density tp_inc tp_diversity tp_homicide tp_media tp_resident tp_male tp_age if sht_black | sht_hispanic, absorb(geoid_blkgrp#semester mystd_id cohort#year) cluster(match_zip)

//TABLE A.V - COMPARING ABSENTEEISM EFFECTS OF POLICE AND CRIMINAL VIOLENCE
use attendance_violence, clear

reghdfe absent tp_police tp_criminal, absorb(geoid_tract#date mystd_id) cluster(match_zip)
reghdfe absent tp_police tp_criminal if restricted, absorb(geoid_tract#date mystd_id) cluster(match_zip)
reghdfe absent tp_police tp_criminal, absorb(geoid_blkgrp#date mystd_id) cluster(match_zip)
reghdfe absent tp_police tp_criminal if restricted, absorb(geoid_blkgrp#date mystd_id) cluster(match_zip)

//TABLE A.VI - COMPARING GPA EFFECTS OF POLICE AND CRIMINAL VIOLENCE BY RACE
use gpa_violence_type, clear

reghdfe gpa police_both criminal_both, absorb(mystd_id geoid_blkgrp#semester cohort#year) cluster(match_zip)
reghdfe gpa police_both criminal_both crimes arrests, absorb(mystd_id geoid_blkgrp#semester cohort#year) cluster(match_zip)
reghdfe gpa police_minority police_whiteasian criminal_minority criminal_whiteasian, absorb(mystd_id geoid_blkgrp#semester cohort#year) cluster(match_zip)
reghdfe gpa police_minority police_whiteasian criminal_minority criminal_whiteasian crimes arrests, absorb(mystd_id geoid_blkgrp#semester cohort#year) cluster(match_zip)

reghdfe gpa police_both criminal_both if std_blackhispanic, absorb(mystd_id geoid_blkgrp#semester cohort#year) cluster(match_zip)
reghdfe gpa police_both criminal_both crimes arrests if std_blackhispanic, absorb(mystd_id geoid_blkgrp#semester cohort#year) cluster(match_zip)
reghdfe gpa police_minority police_whiteasian criminal_minority criminal_whiteasian if std_blackhispanic, absorb(mystd_id geoid_blkgrp#semester cohort#year) cluster(match_zip)
reghdfe gpa police_minority police_whiteasian criminal_minority criminal_whiteasian crimes arrests if std_blackhispanic, absorb(mystd_id geoid_blkgrp#semester cohort#year) cluster(match_zip)

//TABLE A.VII - COMPARING GPA EFFECTS OF POLICE AND GANG-RELATED VIOLENCE
use gpa_violence_type, clear

reghdfe gpa police_both criminal_gang criminal_nongang, absorb(mystd_id geoid_blkgrp#semester cohort#year) cluster(match_zip)
reghdfe gpa police_both criminal_gang criminal_nongang crimes arrests, absorb(mystd_id geoid_blkgrp#semester cohort#year) cluster(match_zip)
reghdfe gpa police_both criminal_gang criminal_nongang if std_blackhispanic, absorb(mystd_id geoid_blkgrp#semester cohort#year) cluster(match_zip)
reghdfe gpa police_both criminal_gang criminal_nongang crimes arrests if std_blackhispanic, absorb(mystd_id geoid_blkgrp#semester cohort#year) cluster(match_zip)

//TABLE A.VIII - EFFECTS ON CUMULATIVE GPA: ALTERNATIVE STANDARD ERRORS
use longrun, clear

local controls = "school treat expected_grade cst_level poverty parent_edu male home_english black hispanic asian other male" 

reghdfe gpa_cum ib13.t_expected if sample1 & n_grade<=1, absorb(cohort#geoid_blkgrp `controls') cluster(mystd_id)
reghdfe gpa_cum ib13.t_expected if sample1 & n_grade<=1, absorb(cohort#geoid_blkgrp `controls') cluster(mystd_id cohort)
reghdfe gpa_cum ib13.t_expected if sample1 & n_grade<=1, absorb(cohort#geoid_blkgrp `controls') cluster(zip)
reghdfe gpa_cum ib13.t_expected if sample1 & n_grade<=1, absorb(cohort#geoid_blkgrp `controls') cluster(geoid_tract)